export function flat(array) {
    if (array.length === 0) {
        return [];
    }
    const res = [];
    const queue = []
    queue.push(array);

    while (queue.length !== 0) {
        const item = queue.shift();
        if (item instanceof Array) {
            for (let i = item.length - 1; i >= 0; i --) {
                queue.unshift(item[i]);
            }
        } else {
            res.push(item);
        }
        
    }
    return res;
}